import React, { Component } from 'react'
import HelloWorld from './HelloWorld'

export default class App extends Component {
  constructor() {
    super()
    this.state = {
      isShow: true,
    }
  }

  showHelloWorld() {
    this.setState({
      isShow: !this.state.isShow,
    })
  }

  render() {
    const { isShow } = this.state

    return (
      <div>
        哈哈哈
        <button onClick={(e) => this.showHelloWorld()}>切换</button>
        {/* 每一个组件都是类的实例对象，会依次执行实例对象的constructor方法和render方法 */}
        {isShow && <HelloWorld />}
        {/* <HelloWorld /> */}
      </div>
    )
  }
}
